package com.itheima.d4_byte_stream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class FileInputStreamTest2 {
    public static void main(String[] args) throws IOException {
        InputStream is = new FileInputStream("C:\\Users\\dell\\IdeaProjects\\file-io-app\\src\\itheima02.txt");
        /*
        byte[] buffer=new byte[3];
        int len=is.read(buffer);
        String rs=new String(buffer);
        System.out.println(rs);
        System.out.println("当前读取的字节数量："+len);

        int len2=is.read(buffer);
        String rs2=new String(buffer,0,len2);
        System.out.println(rs2);
        System.out.println("当前读取的字节数量："+len2);

        int len3=is.read(buffer);
        System.out.println("当前读取的字节数量："+len3);*/

        //读取汉字乱码
        byte [] buffer=new byte[3];
        int len;
        while((len=is.read(buffer))!=-1){
             String rs=new String(buffer,0,len);
            System.out.print(rs);
        }
        is.close();
    }
}
